package educationaladministrationsystem.CSM.Controller.StudentAndTeacher.Student;

import educationaladministrationsystem.Result.Result;
import educationaladministrationsystem.CSM.Mapper.Service.StudentAndTeacher.Student.StudentElectiveCourseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("Student/Elective")
public class StudentElectiveCourseController {
    @Autowired
    private StudentElectiveCourseService studentElectiveCourseService;

    @GetMapping("/getAllCourse")
    public Result getAllCourse(@RequestParam int page, @RequestParam int pageNumber) {
        return Result.success(studentElectiveCourseService.getAllCourse(page, pageNumber));
    }

    @GetMapping("/getAllCoursePage")
    public Result getAllCoursePage(@RequestParam int pageNumber) {
        return Result.success(studentElectiveCourseService.getAllCoursePage(pageNumber));
    }

    @PostMapping("/addNewCourse")
    public Result addNewCourse(@RequestParam String UID, @RequestParam String classId) {
        studentElectiveCourseService.addNewCourse(UID, classId);
        return Result.success();
    }

    @GetMapping("/peopleNumAndSum")
    public Result peopleNumAndSum(@RequestParam String classId) {
        return Result.success(studentElectiveCourseService.peopleNumAndSum(classId));
    }

    @PostMapping("/updateCoursePeopleNumber")
    public Result updateCoursePeopleNumber(@RequestParam int peopleNumber, @RequestParam String classId) {
        studentElectiveCourseService.updateCoursePeopleNumber(peopleNumber, classId);
        return Result.success();
    }

    @PostMapping("/deleteCourse")
    public Result deleteCourse(@RequestParam String UID, @RequestParam String classId) {
        studentElectiveCourseService.deleteCourse(UID, classId);
        return Result.success();
    }

    @GetMapping("/getHaveSelectCourse")
    public Result getHaveSelectCourse(@RequestParam String UID) {
        return Result.success(studentElectiveCourseService.getHaveSelectCourse(UID));
    }

    @GetMapping("/getDegree")
    public Result getDegree(@RequestParam String UID) {
        return Result.success(studentElectiveCourseService.getDegree(UID));
    }

    @GetMapping("/getCourseDegreeDemand")
    public Result getCourseDegreeDemand(@RequestParam String classId) {
        return Result.success(studentElectiveCourseService.getCourseDegreeDemand(classId));
    }
}
